<script setup>
import { introApi } from "@/services/index";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { nextTick, ref, watch, onMounted } from "vue";
import { appInfo, loginSwitch } from "@/services/user";
import topNav from "../../components/topNav.vue";
import code from "@/static/cashier/code.png";
import sand from "@/static/cashier/sand.png";
import num from "@/static/cashier/num.png";
import { operation } from "@/utils/num.js";

// @param op { string } 运算类型，有加减乘除（add / subtract / multiply / divide）

import { appOrderUpdate, appPayCreate } from "@/services/cashier";

const orderId = ref("");
const discountRate = ref("");

const oddFee = ref("");
const payUnpaidFee = ref(0);
const payDiscount = ref(0);
const payTotalPrice = ref(0);
const payYh = ref(0);
const payNum = ref(0);
const attach = ref("scan_pay");
const payUnpaidFeeInput = ref(0);
const inputDiscountRate = ref("");
const orderid = ref("");
const subject = ref("");

const isInput = ref(false);
const payPrice = ref(0);
const upPrice = ref(0);
const oldPayPrice = ref(0);
const oldZk = ref(0);
//改总价的优惠
const newUpPrice = ref(0);

onLoad((e) => {
  orderId.value = e.id ? e.id : "";
  orderid.value = e.id ? e.id : "";
  console.log(e, orderId.value);
  payNum.value = e.payNum ? e.payNum : 0;
  payPrice.value = e.price ? e.price : 0;
  payTotalPrice.value = e.price ? e.price : 0;
  payUnpaidFee.value = e.price ? e.price : 0;
  oldPayPrice.value = e.price ? e.price : 0;
  newUpPrice.value = e.newUpPrice ? e.newUpPrice : 0;
  // if (e.upPrice > 0) {
  //   oddFee.value = e.upPrice ? e.upPrice : "";
  //   upPrice.value = e.upPrice ? e.upPrice : "";
  // }
  if (newUpPrice.value > 0 || e.upPrice < 0) {
    newOrderUpdate();
  }
  // getAppOrderUpdate();
});
onShow(() => {
  subject.value = "";
});
const inputChange = (e) => {
  oddFee.value = 0;
  if (!inputDiscountRate.value) {
    selectIndex.value = discountRateList.value.length - 1;
    console.log(selectIndex.value);
  } else {
    if (e > 100 || e < 0) {
      uni.showToast({
        title: "折扣率应在0-100之间",
        icon: "none",
      });
      if (e > 100) {
        setTimeout(() => {
          inputDiscountRate.value = 100;
        }, 100);
      }
      if (e <= 0) {
        setTimeout(() => {
          inputDiscountRate.value = 0;
        }, 100);
      }

      return;
    }
    setTimeout(() => {
      inputDiscountRate.value = parseInt(e);
    }, 100);
    isInput.value = true;
    selectIndex.value = -1;
    console.log(selectIndex.value);
  }
};
const newOrderUpdate = async () => {
  let data = {};
  if (newUpPrice.value == 0) {
    return;
  }
  data = {
    id: orderId.value,

    oddFee: newUpPrice.value ? newUpPrice.value : "",
  };
  try {
    let res = await appOrderUpdate(data);
    if (res.code == 200) {
      // let resData = res.data.datas;
      orderid.value = res.data.id;
      payTotalPrice.value = res.data.totalGoodsAmount;
      payUnpaidFee.value = res.data.totalAmount;

      // payUnpaidFee.value =
      //   payDiscount.value > 0
      //     ? res.data.totalGoodsDiscount
      //     : res.data.totalGoodsAmount;
      payDiscount.value = res.data.totalDiscountRate;
      payYh.value = res.data.totalGoodsDiscount;
      oldPayPrice.value = res.data.totalAmount;
    } else {
      uni.showToast({
        title: res.msg,
        icon: "none",
        mask: true,
      });
    }
  } catch (e) {
    uni.showToast({
      title: e.msg,
      icon: "none",
      mask: true,
    });
  }
};

const getAppOrderUpdate = async () => {
  let data = {};
  if (oddFee.value > 0) {
    data = {
      id: orderId.value,

      oddFee: oddFee.value ? oddFee.value : "",
    };
    if (payDiscount.value > 0) {
      data.discountRate = payDiscount.value;
    }
  } else {
    data = {
      id: orderId.value,
      oddFee: oddFee.value ? oddFee.value : "",
    };
    if (payDiscount.value > 0) {
      data.discountRate = payDiscount.value;
    }
  }
  console.log("getAppOrderUpdate", payDiscount.value, data);

  try {
    let res = await appOrderUpdate(data);
    if (res.code == 200) {
      // let resData = res.data.datas;
      orderid.value = res.data.id;
      payTotalPrice.value = res.data.totalGoodsAmount;
      payUnpaidFee.value = res.data.totalAmount;

      // payUnpaidFee.value =
      //   payDiscount.value > 0
      //     ? res.data.totalGoodsDiscount
      //     : res.data.totalGoodsAmount;
      payDiscount.value = res.data.totalDiscountRate;
      payYh.value = res.data.totalGoodsDiscount;
      oldPayPrice.value = res.data.totalAmount;
    } else {
      uni.showToast({
        title: res.msg,
        icon: "none",
        mask: true,
      });
    }
  } catch (e) {
    uni.showToast({
      title: e.msg,
      icon: "none",
      mask: true,
    });
  }
};

const saveFun = () => {
  console.log("保存");
};
const value = ref(0);
const show = ref(false);
// 定义方法
function valChange(e) {
  console.log("当前值为: " + e.target.value);
}
const confirmModal = () => {
  console.log("当前值为: ");
  show.value = false;
};
const rightClick = () => {
  console.log("rightClick");
};

const leftClick = () => {
  console.log("leftClick");
};

const ishowcamera = ref(false);

const isPayTo = ref(false);

const goPay = async () => {
  if (isPayTo.value) {
    return;
  }
  isPayTo.value = true;

  console.log("sdasdas", orderid.value);
  if (attach.value == "scan_pay") {
    // #ifdef H5
    uni.navigateTo({
      url:
        "/pages/code_sand/index?type=payPrice" +
        "&orderid=" +
        orderid.value +
        "&payNum=" +
        payNum.value +
        "&payPrice=" +
        (attach.value == "cash_pay"
          ? payUnpaidFeeInput.value
          : payUnpaidFee.value),
    });
    isPayTo.value = false;
    // #endif

    // #ifdef APP-PLUS
    const systemInfo = uni.getSystemInfoSync();
    if (systemInfo.osName === "android") {
      if (uni.getStorageSync("isspermission")) {
      } else {
        ishowcamera.value = true;
      }

      plus.android.requestPermissions(["android.permission.CAMERA"], (e) => {
        if (e.deniedAlways.length > 0) {
          // 弹出提示框解释为何需要权限，引导用户打开设置页面开启

          ishowcamera.value = false;
        } else if (e.deniedPresent.length > 0) {
          //权限被临时拒绝
          // 弹出提示框解释为何需要权限，可再次调用plus.android.requestPermissions申请权限
          ishowcamera.value = false;
        } else if (e.deniedAlways.length > 0) {
          //权限被永久拒绝
          // 弹出提示框解释为何需要权限，可再次调用plus.android.requestPermissions申请权限
          ishowcamera.value = false;
        } else {
          plus.android.requestPermissions(
            ["android.permission.READ_EXTERNAL_STORAGE"],
            (e) => {
              if (e.deniedAlways.length > 0) {
                // 弹出提示框解释为何需要权限，引导用户打开设置页面开启

                ishowcamera.value = false;
              } else if (e.deniedPresent.length > 0) {
                //权限被临时拒绝
                // 弹出提示框解释为何需要权限，可再次调用plus.android.requestPermissions申请权限

                ishowcamera.value = false;
              } else if (e.deniedAlways.length > 0) {
                //权限被永久拒绝
                // 弹出提示框解释为何需要权限，可再次调用plus.android.requestPermissions申请权限

                ishowcamera.value = false;
              } else {
                ishowcamera.value = false;
                uni.setStorageSync("isspermission", true);

                uni.scanCode({
                  scanType: ["barCode", "qrCode"],
                  autoDecodeCharset: true,
                  autoZoom: true,
                  success: async function (res) {
                    console.log("条码类型：" + res.scanType);
                    console.log("条码内容：" + res.result);

                    try {
                      uni.showLoading({
                        title: "收款中",
                      });
                      let res2 = await appPayCreate({
                        id: orderid.value,
                        attach: "scan_pay",
                        authCode: res.result,
                        subject: subject.value,
                      });
                      console.log(res);
                      if (res2.code == 200) {
                        uni.reLaunch({
                          url:
                            "/pages/cashier/paystate/index?orderid=" +
                            res2.data.id +
                            "&payNum=" +
                            payNum.value +
                            "&payPrice=" +
                            (attach.value == "cash_pay"
                              ? payUnpaidFeeInput.value
                              : payUnpaidFee.value),
                        });
                        isPayTo.value = false;
                      } else {
                        uni.showToast({
                          title: res2.msg,
                          icon: "none",
                        });
                        isPayTo.value = false;
                      }
                    } catch (e) {
                      console.log(e);
                      isPayTo.value = false;
                      uni.showToast({
                        title: e.msg ? e.msg : e,
                        icon: "none",
                      });
                    }

                    // uni.navigateTo({
                    //   url: "/pages/cashier/paystate/index?orderid=" + res.result,
                    // });
                  },
                });
              }
            }
          );
        }
      });
      return;
    }
    uni.scanCode({
      scanType: ["barCode", "qrCode"],
      autoDecodeCharset: true,
      autoZoom: true,
      success: async function (res) {
        console.log("条码类型：" + res.scanType);
        console.log("条码内容：" + res.result);

        try {
          uni.showLoading({
            title: "收款中",
          });
          let res2 = await appPayCreate({
            id: orderid.value,
            attach: "scan_pay",
            authCode: res.result,
            subject: subject.value,
          });
          console.log(res);
          if (res2.code == 200) {
            uni.reLaunch({
              url:
                "/pages/cashier/paystate/index?orderid=" +
                res2.data.id +
                "&payNum=" +
                payNum.value +
                "&payPrice=" +
                (attach.value == "cash_pay"
                  ? payUnpaidFeeInput.value
                  : payUnpaidFee.value),
            });
            isPayTo.value = false;
          } else {
            uni.showToast({
              title: res2.msg,
              icon: "none",
            });
            isPayTo.value = false;
          }
        } catch (e) {
          console.log(e);
          uni.showToast({
            title: e.msg ? e.msg : e,
            icon: "none",
          });
          isPayTo.value = false;
        }

        // uni.navigateTo({
        //   url: "/pages/cashier/paystate/index?orderid=" + res.result,
        // });
      },
    });

    // #endif
  }
  if (attach.value == "cash_pay") {
    try {
      uni.showLoading({
        title: "收款中",
      });
      let res = await appPayCreate({
        id: orderid.value,
        attach: "cash_pay",
        subject: subject.value,
      });
      if (res.code == 200) {
        uni.reLaunch({
          url:
            "/pages/cashier/paystate/index?orderid=" +
            res.data.id +
            "&payNum=" +
            payNum.value +
            "&payPrice=" +
            (attach == "cash_pay"
              ? payUnpaidFeeInput.value
              : payUnpaidFee.value),
        });
        isPayTo.value = false;
      } else {
        uni.showToast({
          title: res.msg,
          icon: "none",
        });
        isPayTo.value = false;
      }
    } catch (e) {
      uni.showToast({
        title: e.msg,
        icon: "none",
      });
      isPayTo.value = false;
    }
  }
  if (attach.value == "app_pay") {
    uni.navigateTo({
      url:
        "/pages/cashier/code/index?orderid=" +
        orderid.value +
        "&payNum=" +
        payNum.value +
        "&payPrice=" +
        (attach == "cash_pay" ? payUnpaidFeeInput.value : payUnpaidFee.value),
    });
    isPayTo.value = false;
  }

  // uni.re({
  //   url: "/pages/cashier/goods_confirm/index",
  // });
};

//支付方式
const payList = ref([
  {
    name: "扫码支付",
    icon: sand,
    value: 1,
    payText: "scan_pay",
  },
  // {
  //   name: "二维码收款",
  //   icon: code,
  //   value: 2,
  //   payText: "app_pay",
  // },
  {
    name: "现金",
    icon: num,
    value: 3,
    payText: "cash_pay",
  },
]);

const discountRateList = ref([
  {
    name: "9.5折",
    value: 95,
    type: 1,
  },
  {
    name: "9折",
    value: 90,
    type: 1,
  },
  {
    name: "8.5折",
    value: 85,
    type: 1,
  },
  {
    name: "8折",
    value: 80,
    type: 1,
  },
  {
    name: "7.5折",
    value: 75,
    type: 1,
  },
  {
    name: "7折",
    value: 70,
    type: 1,
  },
  {
    name: "6.5折",
    value: 65,
    type: 1,
  },
  {
    name: "6折",
    value: 60,
    type: 1,
  },
  {
    name: "抹零",
    value: 0,
    type: 2,
  },
  {
    name: "无折扣",
    value: "",
    type: 1,
  },
]);

const selectIndex = ref(discountRateList.value.length - 1);
const showPrice = ref(false);
const closePrice = () => {
  showPrice.value = false;
};
const openPrice = () => {};
const numValue = ref(10);
const selectitemOBJ = ref({});
const selectItem = (item, index) => {
  selectIndex.value = index;
  selectitemOBJ.value = item;
  inputDiscountRate.value = "";
  isInput.value = false;
};
const goCarPay = () => {
  uni.redirectTo({
    url: "/pages/cashier/goodsPayList/index",
  });
};
const confirmZK = () => {
  // console.log(!inputDiscountRate.value, inputDiscountRate.value == true);
  // if (!inputDiscountRate.value && selectIndex.value != -1) {
  //   selectIndex.value = discountRateList.value.length - 1;
  // } else {
  //   selectIndex.value = -1;
  //   payDiscount.value = 1;
  //   getAppOrderUpdate();

  //   return;
  // }
  if (isInput.value) {
    console.log("inputDiscountRate.value", inputDiscountRate.value);
    if (inputDiscountRate.value > 0) {
      // discountRate.value = inputDiscountRate.value / 10;
      discountRate.value = operation(
        Number(inputDiscountRate.value),
        10,
        2,
        "divide"
      );

      payDiscount.value = operation(
        Number(inputDiscountRate.value),
        100,
        2,
        "divide"
      );

      selectIndex.value = -1;
    } else {
      selectIndex.value = -1;
      payDiscount.value = 0;
    }
    showPrice.value = false;
    oldZk.value = payDiscount.value ? payDiscount.value : 0;
    attach.value = "scan_pay";
    getAppOrderUpdate();
    return;
  }
  if (selectitemOBJ.value.type == 1) {
    oddFee.value = 0;
    discountRate.value = operation(selectitemOBJ.value.value, 10, 2, "divide");
    payDiscount.value = operation(
      selectitemOBJ.value.value ? selectitemOBJ.value.value : 100,
      100,
      2,
      "divide"
    );
    oldZk.value = payDiscount.value ? payDiscount.value : 0;
    attach.value = "scan_pay";
  } else if (selectitemOBJ.value.type == 2) {
    console.log("selectitemOBJ.value", selectitemOBJ.value);
    // 18.1 parseInt(18
    //   .1
    // )
    discountRate.value = 0;
    payDiscount.value = 0;
    oddFee.value = operation(
      Number(payUnpaidFee.value),
      parseInt(payUnpaidFee.value),
      2,
      "subtract"
    );
    console.log(parseInt(18.1));
    // if (upPrice.value > 0) {
    //   oddFee.value = upPrice.value;
    // } else {

    // }

    // discountRate.value = 1;
    if (oddFee.value <= 0) {
      uni.showToast({
        title: "该金额无须抹零",
        icon: "none",
      });
      showPrice.value = false;
      return;
    }
  }
  showPrice.value = false;

  getAppOrderUpdate();
};

const selectPayItem = (item, index) => {
  attach.value = item.payText;
  let ml = 0;

  if (item.payText == "cash_pay") {
    return;
    payUnpaidFeeInput.value = operation(
      Math.floor(operation(Number(payUnpaidFee.value), 10, 2, "multiply")),
      10,
      2,
      "divide"
    );

    ml = operation(
      Number(oldPayPrice.value),
      Number(payUnpaidFeeInput.value),
      2,
      "subtract"
    );

    console.log("12321232", ml, oldPayPrice.value);

    oddFee.value = operation(
      operation(
        Number(payTotalPrice.value),
        Number(oldPayPrice.value),
        2,
        "subtract"
      ),
      Number(ml),
      2,
      "add"
    );

    if (ml > 0) {
      payDiscount.value = 0;
      getAppOrderUpdate();
    }
  } else {
    if (isPayInput.value) {
      oddFee.value = operation(
        Number(payTotalPrice.value),
        Number(priceValue.value),
        2,
        "subtract"
      );
      getAppOrderUpdate();
      return;
    }
    console.log(oldZk.value, payDiscount.value);

    if (oldZk.value > 0) {
      payDiscount.value = oldZk.value;
      oddFee.value = "";
      console.log("123123123", payDiscount.value);
      getAppOrderUpdate();
    } else {
      payDiscount.value = 1;
      oddFee.value = "";
      getAppOrderUpdate();
    }
  }
};

const keyWord = ref(null);
const priceValue = ref(0);
const selectNumIndex = ref(-1);
const del = (e) => {
  if (e == 0) {
    selectNumIndex.value = selectNumIndex.value - 1;
  } else if (e == 1) {
    selectNumIndex.value = selectNumIndex.value + 1;
  }
};
const keyWordItem = (index) => {
  selectNumIndex.value = index;
};
const inp = (e) => {};

const hide = () => {
  // if (num.value > 0) {
  // } else {
  //   jsnum.value = 0;
  // }
  // isPayShow.value = false;
  keyWord.value.close();
};
const isPayInput = ref(false);

//輸入金額

const confirm = async () => {
  if (priceValue.value <= 0) {
    uni.showToast({
      title: "请输入正确金额",
      icon: "none",
    });
    return;
  }
  if (
    operation(
      Number(payTotalPrice.value),
      Number(priceValue.value),
      2,
      "subtract"
    ) < 0
  ) {
    uni.showToast({
      title: "实收金额不能大于应收金额",
      icon: "none",
    });
    return;
  }
  if (attach.value == "cash_pay") {
    let ml = operation(
      Math.floor(operation(Number(priceValue.value), 10, 2, "multiply")),
      10,
      2,
      "divide"
    );

    oddFee.value = operation(
      Number(payTotalPrice.value),
      Number(ml),
      2,
      "subtract"
    );
  } else {
    oddFee.value = operation(
      Number(payTotalPrice.value),
      Number(priceValue.value),
      2,
      "subtract"
    );
  }

  selectIndex.value = discountRateList.value.length - 1;
  inputDiscountRate.value = "";
  payDiscount.value = 0;
  discountRate.value = "";
  // oddFee.value = 0;
  if (oddFee.value > 0) {
    isPayInput.value = true;
    getAppOrderUpdate();
  }
};
const closePay = () => {
  // isPayShow.value = false;
  keyWord.value.close();
};
const goPriceClick = () => {
  priceValue.value = String(payUnpaidFee.value);
  selectNumIndex.value = -1;
  keyWord.value.open();
};
const showBj = ref(false);
const value2 = ref("");

const beizfun = () => {
  showBj.value = false;
  subject.value = value2.value;
};
</script>

<template>
  <view class="bg">
    <jia-PayKeyboard
      :confirmStyle="{ backgroundColor: '#1679FB' }"
      class="keyWord-index"
      :overlayClose="true"
      ref="keyWord"
      v-model="priceValue"
      :sclectItem="selectNumIndex"
      @del="del"
      @input="inp"
      @confirm="confirm"
      @hide="hide"
    >
      <view class="PayKeyboard-k">
        <view class="icon-top">
          <up-icon
            @click="closePay"
            name="close"
            color="#86909C"
            size="30rpx"
          ></up-icon
        ></view>
        <view class="PayKeyboard-k-title"
          ><text>{{ "修改价格" }}</text>
        </view>
        <view class="link-to"></view>
        <view class="PayKeyboard-k-num">
          <view class="PayKeyboard-k-num-title">价格</view>
          <view class="PayKeyboard-k-num-input">
            <up-form labelPosition="left" ref="form1" labelWidth="0">
              <up-form-item
                label=" "
                borderBottom
                ref="item1"
                @click="keyWordItem(-1)"
              >
                <view class="PayKeyboard-k-num-input-text">
                  <view
                    class="num-view"
                    v-for="(item, index) in priceValue"
                    :key="index"
                    @click.stop="keyWordItem(index)"
                    ><view
                      class="input_lin"
                      v-if="selectNumIndex == index"
                    ></view
                    >{{ item }}</view
                  >
                  <view class="input_lin" v-if="selectNumIndex == -1"></view>
                </view>
                <template #right>
                  <text>元</text>
                </template>
              </up-form-item>
            </up-form>
          </view>
        </view>
      </view>
    </jia-PayKeyboard>

    <up-navbar
      title="手机收银"
      bgColor="#ffffff"
      @rightClick="rightClick"
      :autoBack="true"
      :safeAreaInsetTop="true"
      :fixed="true"
      :placeholder="true"
      :leftText="'返回'"
      :border="true"
    >
      <template #right> </template>
    </up-navbar>

    <view class="content">
      <view class="content_info">
        <view class="content_info_index">
          <text class="content_info_index_text">订单应收</text>
          <text class="nun">¥{{ payTotalPrice }}</text>
        </view>
        <!-- @click="showPrice = true" -->
        <view class="content_info_index">
          <text class="content_info_index_text">整单折扣</text>
          <view class="nun"
            ><text class="red">{{
              discountRate ? "-" + discountRate + "折" : "无折扣"
            }}</text>
            <up-icon name="arrow-right" color="#C9CDD4" size="40rpx"></up-icon
          ></view>
        </view>
        <view class="content_info_index" @click="showBj = true">
          <text class="content_info_index_text">订单备注</text>
          <view class="bj"
            ><text>{{ subject ? subject : "无备注" }}</text>
            <up-icon name="arrow-right" color="#C9CDD4" size="40rpx"></up-icon
          ></view>
        </view>
        <view class="content_info_title">实收金额</view>
        <!-- @click="goPriceClick" -->
        <view class="content_info_index">
          <text class="content_info_paynum">{{ payUnpaidFee }}</text>
          <text class="content_info_pay_uit">元</text>
        </view>

        <view class="content_info_pay_to"
          ><text>应付金额:</text> ¥{{ payUnpaidFee }}</view
        >
      </view>
    </view>
    <view class="pay_type">选择付款方式</view>
    <view class="pay_list">
      <view
        class="pay_list_item"
        v-for="(item, index) in payList"
        :key="index"
        @click="selectPayItem(item, index)"
      >
        <view class="pay_list_item_left">
          <view class="pay_list_item_left_img">
            <image :src="item.icon" mode="widthFix"></image>
          </view>
          <text>{{ item.name }}</text>
        </view>
        <view class="pay_list_item_right" v-if="item.payText == attach">
          <up-icon name="checkbox-mark" color="#1679FB" size="40rpx"></up-icon>
        </view>
      </view>
    </view>
  </view>

  <view class="bt_form" v-if="!showPrice" v-permission="['shop:pay:create']">
    <view class="bt_form_k">
      <view class="bt_form_k_left">
        <view class="icon_car" @click="goCarPay()">
          <view class="box">
            <up-badge :value="payNum"></up-badge>
          </view>
          <image src="../../../static/cashier/car.png" mode="scaleToFill" />
        </view>
        <view class="price" @click="goCarPay()">
          <view class="price-nums"
            ><text>¥</text>
            {{ payUnpaidFee }}
            <!-- {{ attach == "cash_pay" ? payUnpaidFeeInput : payUnpaidFee }} -->
            <!-- <up-icon name="arrow-up" color="#ff5722" size="28rpx"></up-icon> -->
          </view>
          <view class="price_yh">优惠¥{{ payYh }}</view>
        </view>

        <!-- <view class="num_jt"></view> -->
      </view>
      <view class="bt_pay" :class="isPayTo ? 'noActive' : ''" @click="goPay"
        >去结账</view
      >
    </view>
  </view>

  <up-modal
    :show="show"
    title="温馨提示"
    :showCancelButton="true"
    confirmText="确认"
    cancelText="取消"
    @cancel="show = false"
    @confirm="confirmModal"
  >
    <view class="slot-content">
      <rich-text :nodes="'确定要删除已选商品吗？'"></rich-text>
    </view>
  </up-modal>

  <up-popup
    round="10"
    :show="showPrice"
    :closeable="true"
    :safeAreaInsetBottom="true"
    @close="closePrice"
    @open="openPrice"
  >
    <view class="popup-content">
      <view class="price-title">选择整单折扣</view>
      <view class="price-input">
        <view class="price-input-left">直接输入折扣如8折输入80</view>
        <view class="price-input-right">
          <up-input
            class="price-input-right-input"
            placeholder="请输入内容"
            border="none"
            type="digit"
            min="1"
            :clearable="true"
            v-model="inputDiscountRate"
            @change="inputChange"
          ></up-input>
        </view>
      </view>
      <view class="price-zk">
        <view class="price-zk-title">折扣</view>
        <view class="price-zk-list">
          <!-- <view class="price-zk-list-item price-zk-list-selectitem">
            95折
          </view> -->
          <view
            class="price-zk-list-item"
            @click="selectItem(item, index)"
            :class="selectIndex == index ? 'price-zk-list-selectitem' : ''"
            v-for="(item, index) in discountRateList"
            :key="index"
          >
            {{ item.name }}
          </view>
        </view>
      </view>
      <view class="price-btn">
        <up-button
          type="default"
          class="price-btn-left"
          :plain="true"
          text="关闭"
          @click="showPrice = false"
        ></up-button>
        <up-button
          @click="confirmZK"
          type="primary"
          class="price-btn-right"
          text="确定"
        ></up-button>
      </view>
    </view>
  </up-popup>

  <up-popup
    round="10"
    :show="showBj"
    :safeAreaInsetBottom="true"
    @close="showBj = false"
    @open="openPrice"
  >
    <view class="popup-content">
      <view class="price-title price-title-bj">
        <text @click="showBj = false" class="bj-qx">取消</text>
        <text>订单备注</text>
        <text class="bj-qx" @click="beizfun">确定</text></view
      >
      <view class="price-content price-content-bj">
        <up-textarea
          style="height: 300rpx"
          v-model="value2"
          placeholder="选填"
          count
        ></up-textarea>
      </view>
    </view>
  </up-popup>
  <view class="show-camera" v-if="ishowcamera">
    <view class="show-camera-k">
      <view class="show-sm"> 设备权限使用说明 </view>
      <view class="show-des">
        为了给您带来更好的服务，需要获取您的相机权限与读取图片及文件权限，用于更换上传图片、扫一扫等功能，对于您授权的信息我们竭尽全力提供安全保护。
      </view>
    </view>
  </view>
</template>

<style lang="scss" scoped>
@import "index.scss";
</style>
